<link rel="stylesheet" href="../addons/jy_merch/css/mobile.css?v=6">
<div   ng-if="pagedata.op!='fa'" class='fui-page fui-page-current'>
    <div class="fui-header fui-header-success" style="background:{{main.syscolor||'#05c175'}}">
        <div class="fui-header-left">
            <a class="back" ng-click="goback();"></a>
        </div>
        <div class="title">订单管理</div>
    </div>
    <!-- 顶部tab -->
    <div id="tab" class="fui-tab fui-tab-success fixed">
			<a ng-class="{'active':pagedata.params.status==1}" ng-click="pagedata.params.status = 1;tool.get_list('jy_merch/manage.order_list/list/',true)">待发货</a>
            <a ng-class="{'active':pagedata.params.status==0}" ng-click="pagedata.params.status = 0;tool.get_list('jy_merch/manage.order_list/list/',true)" >待付款</a>
            <a ng-class="{'active':pagedata.params.status==2}" ng-click="pagedata.params.status = 2;tool.get_list('jy_merch/manage.order_list/list/',true)">待收货</a>
            <a ng-class="{'active':pagedata.params.status==3}" ng-click="pagedata.params.status = 3;tool.get_list('jy_merch/manage.order_list/list/',true)">已完成</a>
            <a ng-class="{'active':pagedata.params.status==4}" ng-click="pagedata.params.status = 4;tool.get_list('jy_merch/manage.order_list/list/',true)">已关闭</a>
    </div>
    <div class='fui-content' style="margin-top:4.6rem">
		<div class="fui-cellone" style="padding-right:0.4rem;z-index: 108;top:0;background:#fff">
			 <div class="fui-cellone-info">
				<div class="search-input" style="height:1.6rem">
					<form action="javascript:return true">
					<i id="searchsub" class="icon icon-sousuo1 bold" ng-click="tool.get_list('jy_merch/manage.order_list/list/',true)" style="line-height: 1.7rem;"></i>
					<input type="search" placeholder="输入订单号" class="search" ng-model="pagedata.params.ordersn" style="border: 1px solid #f9f9f9;height:1.6rem;text-align: left; color: #999; font-size:0.6rem;background:#f9f9f9;border-radius: 1rem;" />
					</form>
				</div>
			 </div>
			<div class="fui-cellone-info" style="padding-left:0.3rem">
				<select class="weui_select" style="padding:0.3rem;border-radius: 1rem;" ng-model="pagedata.params.level">
					<option value="" ng-selected="!pagedata.params.level">选择分类</option>
                    <option ng-repeat="(key,item) in pagedata.levels" value="{{item.id}}">{{item.title}}</option>
				</select>
			</div>
			 <div class="fui-cellone-remark noremark">
			 	<span style="margin-left:0.3rem;font-size: 0.75rem;" ng-click="tool.get_list('jy_merch/manage.order_list/list/',true)">搜索</span>
			 </div>
		</div>
        <!-- 订单列表 -->
		<div style="padding:0 0.5rem">
        <div ng-repeat="item in pagedata.list" class="fui-list-group" style="margin-top:0.2rem">
            <a class="fui-list order-list title-b" ng-click="access_json('/manage.order_detail//id='+item.id)"  data-nocache="true">
                <div class="fui-list-media">
                    <span ng-if='item.ispay==1' class="fui-label fui-label-danger round">{{pagedata.paytype[item.paytype]}}</span>
					<span ng-if='item.ispay==0' class="fui-label fui-label-danger round">未付款</span>
                </div>
                <div class="fui-list-inner">
                    <div class="row">
                        <div class="row-text" style="font-size: 0.7rem; color: #666">{{item.ordersn}}</div>
                    </div>
                    <div class="row gary">
                        <div class="row-text">{{item.createtime}}</div>
                    </div>
                </div>
                <div class="angle"></div>
            </a>
            
                <div ng-repeat="g in item.goods" class="fui-list goods-list">
                    <div class="fui-list-media">
                        <img class="round" ng-src="{{tomedia(g.image)}}"  />
                    </div>
                    <div class="fui-list-inner">
                        <div class="title">{{g.title}}</div>
                        <div class="text" style="color:#f60;font-size:0.50rem">{{g.selespename || '无规格'}} x {{g.total || 1}}</div>
						<div class="text"><i class="fui-tag fui-tag-red">{{item.buytypetitle}}</i></div>
                    </div>
                    <div class="fui-list-angle auto">￥<span class="marketprice">{{g.price}}<br> x{{g.total}}</span></div>
                </div>
           
            <div class="fui-list log-list noclick">
                <div class="fui-list-inner">
                    <div class="row log-row order">
                        <div class="row-text">订单状态</div>
                        <div ng-if="item.send_status!=12" class="row-remark"><span class="text-danger">{{item.statustitle}}</span>（{{item.is_daifa==1?'平台代发':'商户发货'}}）</div>
						<div ng-if="item.send_status==12" class="row-remark"><span class="text-danger">已处理待配送员接单</span></div>
                    </div>
                    <div class="row log-row order">
                        <div class="row-text">买家昵称</div>
                        <div class="row-remark">{{item.nickname}}</div>
                    </div>
                    <div class="row log-row order">
                        <div class="row-text">配送方式</div>
                        <div class="row-remark"><span class="text-success">{{item.sendtypetitle}}</span></div>
                    </div>
					 <div class="row log-row order">
                        <div class="row-text">运费</div>
                        <div class="row-remark">
						<div class="text-success" ng-if="item.buytype==4">{{item.dispatchpricetitle}}：￥{{item.sys_peiprice>0?item.sys_peiprice:item.dispatchprice}}</div>
						<div ng-if="item.sys_peiprice>0 && item.buytype!=4" class="text-success">平台运费：￥{{item.sys_peiprice}}</div>
						</div>
                    </div>
                   <div ng-if="item.remark" class="row log-row order">
                            <div class="row-text">买家留言</div>
                            <div class="row-remark">{{item.remark}}</div>
                    </div>
					<div ng-if="item.selfnumber" class="row log-row order">
                        <div class="row-text">取货号</div>
                        <div class="row-remark"><span class="text-success bold" style="font-size:0.8rem;">#{{item.selfnumber2}}</span></div>
                    </div>     
                </div>
            </div>
            <div class="fui-list-group-title text-right">
                <small class="status">共<span class="text-success">{{item.goodscount}}</span>个商品 实付:<span class="text-success">￥{{item.price}}</span> </small>
            </div>
            <div class="fui-list-group-title text-right big">
                <!-- 未付款 -->
				<a ng-if="item.ispay==0 && item.status<3" ng-click="modal_json({'action':'/manage.order_list/upprice/id='+item.id})"  class="btn btn-sm btn-red order-btn">修改价格</a>
                <a ng-if="item.ispay==0" ng-click="post({},'/manage.order_list/ispay/','id='+item.id,'','请确定，已经线下收到客户的订单款？点击确定后，将订单状态将变成《支付成功》！')"  class="btn btn-sm btn-success order-btn" data-action="payorder" >手动收款</a>
                <!-- 已付款 -->
				<a ng-if="item.is_daifa!=1 && item.status==1 && item.send_status==11" ng-click="post({},'/manage.order_list/jiedan/','id='+item.id)" class="btn btn-sm btn-success order-btn" data-action="payorder">接单</a>
				<a ng-if="item.is_daifa!=1 && item.status==1 && item.send_status==16 && item.buytype==4 && item.needyoufee==1" ng-click="pagedata.nowitem=item;pagedata.showtype=true;" class="btn btn-sm btn-success order-btn">处理发货</a>
				<a ng-if="!item.yungoodsid && pagedata.pluginset.is_daifa==1 && item.is_daifa!=1 && item.status==1 && item.send_status!=12 && item.buytype!=4" ng-click="post({},'/manage.order_list/daifa/','id='+item.id,'','请确定申请让平台代发!')"  class="btn btn-sm btn-success order-btn" data-action="payorder" >申请代发</a>
				<a ng-if="item.is_daifa!=1 && item.status==1 && (item.send_status==0 || item.send_status==8 || item.send_status==16) && (item.buytype!=4 || item.needyoufee!=1)" ng-click="access_json('/manage.order_list/fa/merchfa=2&id='+item.id)" class="btn btn-success btn-sm order-btn" data-action="send" >前往发货</a> 
                <!--<a ng-if="item.status==2" ng-click="post({},'shou','id='+item.id)" class="btn btn-success btn-sm order-btn" data-action="sendcancel">确认收货</a>-->
                <a class="btn btn-default btn-sm" ng-click="access_json('/manage.order_detail//id='+item.id)">查看详情</a>
            </div>
        </div>
        <div ng-if="pagedata.list==''" class="fui-title center" id="content-empty">没有数据</div>
		 </div>
		 </div>
    </div>
    <div class="head-menu-mask"></div>
</div>
<div ng-if="pagedata.op=='fa'" class='fui-page fui-page-current'>
    <div class="fui-header fui-header-success">
        <div class="fui-header-left">        
        </div>
        <div class="title">发货</div>
        <div class="fui-header-right"></div>
    </div>
    <div class='fui-content navbar'>
        <div class="fui-cell-group">
            <div class="fui-cell ">
                <div class="fui-cell-label ">快递公司</div>
                <div class="fui-cell-info">
                    <select class="weui_select" name="select2" ng-model="pagedata.item.express">
                        <option ng-repeat="f in pagedata.express" value="{{f.id}}">{{f.name}}</option>
                    </select>
                <div class="fui-cell-remark"></div>
                </div>
            </div>
            <div class="fui-cell">
                <div class="fui-cell-label">快递单号</div>
                <div class="fui-cell-info">
                    <input type="text" placeholder="请输入快递单号" class="fui-input" ng-model="pagedata.item.expresssn"   id="subtitle" />
                </div>
            </div>
        </div>
	</div>
	<div >
        <div  ng-click="post(pagedata.item,'/manage.order_list/fa/')" class="nav-item btn btn-success btn-submit">确定</div>
   </div>
</div>
<div class="popup" ng-if="pagedata.showtype">
	<div class="popup-body">
		<div class="popup-center" style="padding:1rem;">
			<i class="closed icon icon-cuowu" ng-click="pagedata.showtype=false"></i>
			<div class="weui_btn weui_btn_primary" ng-click="pagedata.post.merchfa=1">自行发货(商家自己私下发货)</div>
			<div class="weui_btn weui_btn_warn" ng-click="pagedata.post.merchfa=2">平台发货(通知平台发货)</div>
			<div class="syscolor c" ng-if="pagedata.post.merchfa==2">需支付运费(￥{{pagedata.nowitem.sys_peiprice ||'0.00'}})</div>
			<div class="weui_btn weui_btn_plain_primary" ng-if="pagedata.post.merchfa==1" style="margin-top:1rem" ng-click="post({},'/manage.order_list/merchfa/merchfa=1&id='+pagedata.nowitem.id)">确认[自行发货]</div>
			<div class="weui_btn weui_btn_plain_primary" ng-if="pagedata.post.merchfa==2" style="margin-top:1rem" ng-click="pagedata.payyoufee(pagedata.nowitem.id)">支付运费[平台发货]</div>
		</div>
	</div>
</div>
<div ng-include="sys_html('_shopfooter')"></div>
<script type="text/javascript">
//手机软键盘--搜索
$("body").keydown(function() {
    if (event.keyCode == "13") {
        $('#searchsub').click();
    }
});
scope.tool.get_list('jy_merch/manage.order_list/list/',true);
scope.pagedata.scroll_bottom=function(){
	scope.tool.get_list('jy_merch/manage.order_list/list/');
}
scope.pagedata.payyoufee=function(orderid){
	scope.post_json('jy_merch/manage.order_list/payyoufee/orderid='+orderid,{},function(res){
		console.log('pay_id');console.log(res);
		scope.pagedata.order_id=res.order_id
		scope.$evalAsync();
		scope.tool.pay(res.pay_id,function(res){
				console.log('收到支付结果！');
				if(res.type=='success'){
					scope.message('支付成功！','','/manage.order_list/');
				}else{
					scope.message('支付失败！'+res.message,'','/manage.order_list/');
				}
		},'','','/manage.order_list/');
	});
}
</script>
